//分类
const utils = require('quanzi-utils');
module.exports = {
	_before: async function() { // 通用预处理器
		this.db = uniCloud.databaseForJQL({
			clientInfo: this.getClientInfo()
		});
		this.userInfo = await utils.getUsetInfo(this);
		this.brand_id = await utils.getshopId(this);
	},
	async update(id, name) {
		return await this.db.collection('mall-categories').doc(id).update({
			name
		});
	},
	async add(data) {
		data.brand_id = this.brand_id;
		return await this.db.collection('mall-categories').add({
			...data
		});
	},
	async delete(id) {
		return await this.db.collection('mall-categories').doc(id).remove();
	},
	async get() {
		return await this.db.collection('mall-categories').where({
			brand_id: this.brand_id
		}).get();
	}

}